import 'package:flutter/material.dart';
import 'package:hi_flutter/data/data.dart';

class MenuPage extends StatelessWidget {
  const MenuPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Hi Flutter'),
      ),
      body: const MenuTitleListView(),
    );
  }
}

class MenuTitleListView extends StatefulWidget {
  const MenuTitleListView({Key? key}) : super(key: key);

  @override
  MenuTitleListViewState createState() => MenuTitleListViewState();
}

class MenuTitleListViewState extends State<MenuTitleListView> {
  late List<AppData> list;

  @override
  void initState() {
    super.initState();
    list = AppDataUtil.getAppDataList();
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      padding: const EdgeInsets.symmetric(horizontal: 16.0),
      itemCount: list.length,
      itemBuilder: (BuildContext buildContext, int index) {
        return Column(
          children: [
            ListTile(
              onTap: (){
                Navigator.of(context).pushNamed(list[index].title, arguments: list[index]);
              },
              title: Text(list[index].title),
            ),
            const Divider(),
          ],
        );
      },
    );
  }
}
